package mm.util;

import java.util.HashMap;
import java.util.Map;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

public class LOG {

	private static final Map<Class, Log> logs = new HashMap<Class, Log>();

	private static final Log DEFAULT_LOG = LogFactory.getLog(LOG.class);

	public static void debug(Object o) {
		DEFAULT_LOG.debug(o);
	}

	public static void debug(Object o, Throwable t) {
		DEFAULT_LOG.debug(o, t);
	}

	public static void debug(Class clazz, Object o) {
		getLog(clazz).debug(o);
	}

	public static void debug(Class clazz, Object o, Throwable t) {
		getLog(clazz).debug(o, t);
	}

	public static void error(Object o) {
		DEFAULT_LOG.error(o);
	}

	public static void error(Object o, Throwable t) {
		DEFAULT_LOG.error(o, t);
	}

	public static void error(Class clazz, Object o) {
		getLog(clazz).error(o);
	}

	public static void error(Class clazz, Object o, Throwable t) {
		getLog(clazz).error(o, t);
	}

	public static void fatal(Object o) {
		DEFAULT_LOG.fatal(o);
	}

	public static void fatal(Object o, Throwable t) {
		DEFAULT_LOG.fatal(o, t);
	}

	public static void fatal(Class clazz, Object o) {
		getLog(clazz).fatal(o);
	}

	public static void fatal(Class clazz, Object o, Throwable t) {
		getLog(clazz).fatal(o, t);
	}

	public static void info(Object o) {
		DEFAULT_LOG.info(o);
	}

	public static void info(Object o, Throwable t) {
		DEFAULT_LOG.info(o, t);
	}

	public static void info(Class clazz, Object o) {
		getLog(clazz).info(o);
	}

	public static void info(Class clazz, Object o, Throwable t) {
		getLog(clazz).info(o, t);
	}

	public static void trace(Object o) {
		DEFAULT_LOG.trace(o);
	}

	public static void trace(Object o, Throwable t) {
		DEFAULT_LOG.trace(o, t);
	}

	public static void trace(Class clazz, Object o) {
		getLog(clazz).trace(o);
	}

	public static void trace(Class clazz, Object o, Throwable t) {
		getLog(clazz).trace(o, t);
	}

	public static void warn(Object o) {
		DEFAULT_LOG.warn(o);
	}

	public static void warn(Object o, Throwable t) {
		DEFAULT_LOG.warn(o, t);
	}

	public static void warn(Class clazz, Object o) {
		getLog(clazz).warn(o);
	}

	public static void warn(Class clazz, Object o, Throwable t) {
		getLog(clazz).warn(o, t);
	}

	private static Log getLog(Class clazz) {
		Log log = logs.get(clazz);
		if (log == null) {
			log = LogFactory.getLog(clazz);
			logs.put(clazz, log);
		}
		return log;
	}

	public static boolean isDebugEnabled() {
		return DEFAULT_LOG.isDebugEnabled();
	}

	public static boolean isDebugEnabled(Class clazz) {
		return getLog(clazz).isDebugEnabled();
	}

	public static boolean isErrorEnabled() {
		return DEFAULT_LOG.isErrorEnabled();
	}

	public static boolean isErrorEnabled(Class clazz) {
		return getLog(clazz).isErrorEnabled();
	}

	public static boolean isFatalEnabled() {
		return DEFAULT_LOG.isFatalEnabled();
	}

	public static boolean isFatalEnabled(Class clazz) {
		return getLog(clazz).isFatalEnabled();
	}

	public static boolean isInfoEnabled() {
		return DEFAULT_LOG.isInfoEnabled();
	}

	public static boolean isInfoEnabled(Class clazz) {
		return getLog(clazz).isInfoEnabled();
	}

	public static boolean isTraceEnabled() {
		return DEFAULT_LOG.isTraceEnabled();
	}

	public static boolean isTraceEnabled(Class clazz) {
		return getLog(clazz).isTraceEnabled();
	}

	public static boolean isWarnEnabled() {
		return DEFAULT_LOG.isWarnEnabled();
	}

	public static boolean isWarnEnabled(Class clazz) {
		return getLog(clazz).isWarnEnabled();
	}

}
